<script type="text/javascript" charset="utf-8" src="<?PHP echo $this->path;?>/xss.js"></script>
<?php if($this->type=='ckeditor'):?>
<style type="text/css">
a.cke_button_off:hover a.cke_button_off:focus a.cke_button_off:active {
    padding: 0px;
    border: 1px #bcbcbc solid;
}
	
.ck-editor .ck-editor__editable {
    min-height: 450px;
}
</style>
<script type="text/javascript" charset="utf-8" src="<?PHP echo $this->path;?>/ckeditor/ckeditor.js"></script>
<script>
    var data;
    var ck=CKEDITOR.replace("<?php echo $this->parm['name'];?>",{
        height:350,
        filebrowserUploadUrl:G_BASE_URL+'/explore/doact/?p=editor&a=upload_file&type=image&cat=<?php echo $this->parm['cat']?>',
        filebrowserHtml5videoUploadUrl:G_BASE_URL+"/?/explore/doact/?p=editor&a=upload_file&type=video&cat=<?php echo $this->parm['cat']?>"
    });
    ck.on('instanceReady', function(editorEvent)
        {
            var data=ck.document.getBody().getHtml();
            // ck.setData(filterXSS(data));
            ck.on( 'fileUploadResponse', function( evt ) {
                // Prevent the default response handler.
                evt.stop();

                // // Get XHR and response.
                var data = evt.data,
                    xhr = data.fileLoader.xhr,
                    response = xhr.responseText.split( '|' );
                if ( response[1] ) {
                    res=eval('('+response[0]+')');
                    data.message = response[ 1 ];
                    evt.cancel();
                } else {
                    response[0]=eval('('+response[0]+')');
                    if(response[0].error){
                    layer.msg (response[0].error.message || response[0].message );

                }else{

                    data.url = response[ 0 ].url;
                    data.linkText = response[ 0 ].fileName;
                }
                }
            } );
        });
</script>
<?php elseif($this->type=='ueditor'):?>

<script type="text/javascript" charset="utf-8" src="<?PHP echo $this->path;?>/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="<?PHP echo $this->path;?>/ueditor/ueditor.all.js"> </script>
<script type="text/javascript" charset="utf-8" src="<?PHP echo $this->path;?>/ueditor/lang/zh-cn/zh-cn.js"></script>

<script type="text/javascript">
var ue = UE.getEditor("<?php echo $this->parm['name'];?>", {
    initialFrameHeight :350,
	autoHeightEnabled: false,
      scaleEnabled:true,
      serverUrl:G_BASE_URL+"/explore/doact/?p=editor&a=upload&cat=<?php echo $this->parm['cat']?>",
	toolbars: [
	    ['fullscreen', 'source', 'undo', 'redo','bold','strikethrough','removeformat','pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc','|','fontfamily','fontsize','insertimage','simpleupload','link','emotion','map','justifyleft','justifyright','justifycenter','attachment','insertvideo','insertcode']
	]
});
ue.ready(function() {
    ue.setContent(filterXSS(ue.getContent()));

});
</script>
<?php else:?>
<script type="text/javascript" charset="utf-8" src="<?PHP echo $this->path;?>/wangeditor/release/wangEditor.js"></script>
<script type="text/javascript" src="<?PHP echo $this->path;?>/wangeditor/plugin/attach/plugin.js"></script>

    <script type="text/javascript">
        var upload_ass="<?php echo $this->user_info['permission']['upload_attach'];?>";
        var E = window.wangEditor
         var $text1 = $('#wangcontent');
        var editor = new E('#<?php echo $this->parm["name"];?>')
        editor.customConfig.onchange = function (html) {
            $text1.val(html)
        }
        editor.customConfig.uploadImgServer = G_BASE_URL+"/explore/doact/?p=editor&a=upload_file&cat=<?php echo $this->parm['cat']?>";
        editor.customConfig.onchangeTimeout = 200;
        editor.customConfig.uploadImgTimeout = <?php echo $this->config['timeout'];?>;
        editor.customConfig.uploadImgMaxSize = <?php echo $this->config['fileMaxSize'];?>*1024*1024;
        editor.customConfig.uploadFileName = 'upload';
        editor.customConfig.uploadImgHooks = {
                fail: function (xhr, editor, result) {
                    console.log(result);
                    if(result.error){
                        layer.msg(result.message);
                        return false;
                    }
                },
                error: function error(xhr, editor) {
                    console.log(xhr);

                },

            }

        
        editor.create()
        editor.txt.html(filterXSS($text1.val()));
         E.attach.init('#<?php echo $this->parm["name"];?>',"<?php echo $this->parm['cat']?>");

        // 初始化 textarea 的值
    </script>
<style type="text/css">
.w-e-toolbar {
    flex-wrap: wrap;
    -webkit-box-lines: multiple;
}
.w-e-toolbar .w-e-menu:hover{
    z-index: 10002!important;
}
.w-e-menu{
    z-index: 1049;
}
.w-e-menu a {
    text-decoration: none;
}
</style>
<?php endif;?>